import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/table';
import { airportList } from '@apps/ant-bus/src/views/business/airport/data/api';
import { employeeList } from '@apps/ant-bus/src/views/business/employeeManage/employee/data/api';
import { vipcardList } from '@apps/ant-bus/src/views/business/goods/vipcard/data/api';
import { render } from '@apps/antd-admin/src/hooks/render/renderUtils';
import { RenderType } from '@pkg/setting';

export const columns: BasicColumn[] = [
  {
    title: '使用时间',
    dataIndex: 'createTime',
    width: 150,
  },
  {
    title: '会员姓名',
    dataIndex: 'userName',
    width: 100,
  },
  {
    title: '会员手机号',
    dataIndex: 'mobile',
    width: 120,
  },
  {
    title: '卡号',
    dataIndex: 'vipCardNo',
    width: 160,
  },
  {
    title: '卡种',
    dataIndex: 'goodsName',
    width: 160,
  },
  {
    title: '开卡日期',
    dataIndex: 'buyDate',
    width: 160,
  },
  {
    title: '价格',
    dataIndex: 'vipPrice',
    width: 170,
  },
  {
    title: '使用次数',
    dataIndex: 'useNum',
    width: 120,
  },
  {
    title: '是否有效',
    dataIndex: 'checkState',
    width: 80,
    dictData: [
      { label: '有效', value: 1, color: '#71ec86' },
      { label: '无效', value: 2, color: '#a6a9a6' },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '目标名称',
    dataIndex: 'targetName',
    width: 170,
  },
  {
    title: '使用机场',
    dataIndex: 'airportName',
    width: 150,
  },
  {
    title: '开卡地区',
    dataIndex: 'openAirportName',
    width: 150,
  },
  {
    title: '服务名称',
    dataIndex: 'serverName',
    width: 120,
  },
  {
    title: '核销员工',
    dataIndex: 'employeeName',
    width: 120,
  },
  {
    title: '使用类型',
    dataIndex: 'checkType',
    width: 120,
    dictData: [
      { label: '会员卡服务', value: 1 },
      { label: '购买单次商品', value: 2 },
      { label: '商家免费饮品', value: 3 },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '补录人',
    dataIndex: 'useCheckUserName',
    width: 120,
  },
  {
    title: '补录时间',
    dataIndex: 'useCheckDate',
    width: 150,
  },
  {
    title: '备注',
    dataIndex: 'remark',
    width: 120,
  },
  {
    title: '核验Id',
    dataIndex: 'checkrecordId',
    width: 200,
  },
  {
    title: '核验关联Id',
    dataIndex: 'parentCheckrecordId',
    width: 200,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'userInfo',
    label: '会员信息',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'vipCardNo',
    label: '卡号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'serverName',
    label: '服务名称',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'checkState',
    label: '是否有效',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '有效', value: 1 },
        { label: '无效', value: 2 },
      ],
    },
  },
  {
    field: 'useNum',
    label: '使用次数',
    component: 'InputNumber',
    colProps: { span: 4 },
  },
  {
    field: 'useAirportIdArray',
    label: '使用机场',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: airportList,
      params: { handlerName: 'busAirportRoleListHandler' },
      labelField: 'airportName',
      valueField: 'airportId',
      immediate: true,
      showSearch: true,
      mode: 'multiple',
    },
  },
  {
    field: 'airportIdArray',
    label: '开卡地区',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: airportList,
      labelField: 'airportName',
      valueField: 'airportId',
      immediate: true,
      showSearch: true,
      mode: 'multiple',
    },
  },
  {
    field: 'employeeIdArray',
    label: '核销员工',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: employeeList,
      params: { handlerName: 'busEmployeeListHandler' },
      labelField: 'employeeName',
      valueField: 'employeeId',
      immediate: true,
      showSearch: true,
      mode: 'multiple',
    },
  },
  {
    field: 'goodsId',
    label: '卡种',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: vipcardList,
      params: { handlerName: 'busVipCardListHandler' },
      labelField: 'goodsName',
      valueField: 'goodsId',
      immediate: true,
      showSearch: true,
    },
  },
  {
    field: 'startDate',
    label: '开始日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endDate',
    label: '结束日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
];
